package 线程基本使用;
//模拟servlet组件
 class LoginServlet{
	 private static String usernameRef;
	 private static String passwordRef;
	 synchronized public static void doPost(String username,String password)
	 {
		 try {
			 usernameRef=username;
			 if(username.equals("a"))
					 {
				 		Thread.sleep(5000);//单位ms,1000ms=1s
					 }
			 passwordRef=password;
			 System.out.println("username="+usernameRef+" password="+ passwordRef);
		 }
		 catch(InterruptedException e)
		 {
			 e.printStackTrace();
		 }
	 }
 }
 class ALogin extends Thread
 {
	 public void run()
	 {
		 LoginServlet.doPost("a", "aa");
	 }
 }
 class BLogin extends Thread
 {
	 public void run()
	 {
		 LoginServlet.doPost("b", "bb");
	 }
 }
public class Test1_17 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ALogin a=new ALogin();
		BLogin b=new BLogin();
		a.start();
		b.start();
	}

}
